<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/14
 * Time: 23:35
 */

namespace frontend\widgets;


use yii\base\Widget;

class Swiper extends Widget
{

    public $model;

    public function run()
    {
        return $this->render('swiper', [
            'model' => $this->model
        ]);
    }

    public function afterRun($result)
    {
        $view = $this->getView();
        $js = "var swiper = new Swiper('.swiper-container', {
                    pagination: {
                        el: '.swiper-pagination',
                        observer: true,//修改swiper自己或子元素时，自动初始化swiper
                        observeParents: true//修改swiper的父元素时，自动初始化swiper
                    },
                });";
        $view->registerJs($js);
        return parent::afterRun($result); // TODO: Change the autogenerated stub
    }
}